import java.util.Comparator;
import java.util.PriorityQueue;
/*class IntBig implements Comparator<Integer> {
    @Override
    //下面方法是什么意思？
    public int compare(Integer o1, Integer o2) {
        return o2.compareTo(o1);
    }
}*/

class student implements Comparable<student>{
    public String name;
    public int age;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int compareTo(student other){
        return this.age - other.age;
    }
}

public class Test {
    public static void main(String[] args) {
        PriorityQueue<student> minHeap = new PriorityQueue<>();

        // 创建 student 对象并添加到队列中
        student s1 = new student();
        s1.setName("Alice");
        s1.setAge(20);
        minHeap.offer(s1);  // 添加 Alice，年龄 20

        student s2 = new student();
        s2.setName("Bob");
        s2.setAge(18);
        minHeap.offer(s2);  // 添加 Bob，年龄 18，Bob 会成为堆顶元素，因为他年龄最小

        student s3 = new student();
        s3.setName("Charlie");
        s3.setAge(22);
        minHeap.offer(s3);  // 添加 Charlie，年龄 22

        System.out.println("Youngest student: " + minHeap.peek().getName() + "," +
                " Age: " + minHeap.peek().getAge());
        // 输出: Youngest student: Bob, Age: 18




    }



    /*public static void main1(String[] args) {
        PriorityQueue<Integer> minHeap = new PriorityQueue<>(new IntBig());//这是什么意思new IntBig()
        minHeap.offer(2);
        minHeap.offer(4);
        minHeap.offer(1);
        System.out.println(minHeap.peek());//
        //System.out.println(minHeap.toString());//
    }*/
}
